{
match self.verbosity {
Quiet => Ok(()),
- _ => self.out().say_status(status, message, GREEN)
+ _ => self.out().say_status(status, message, GREEN, true)
}
}
}
}
- pub fn error<T: ToString>(&mut self, message: T) -> CargoResult<()> {
- self.err().say_status("error", message.to_string(), RED)
+ pub fn error<T: fmt::Display>(&mut self, message: T) -> CargoResult<()> {
+ self.err().say_status("error:", message, RED, false)
}
- pub fn warn<T: ToString>(&mut self, message: T) -> CargoResult<()> {
- self.err().say(message, YELLOW)
+ pub fn warn<T: fmt::Display>(&mut self, message: T) -> CargoResult<()> {
+ self.err().say_status("warning:", message, YELLOW, false)
}
pub fn set_verbosity(&mut self, verbose: bool, quiet: bool) -> CargoResult<()> {
Ok(())
}
- pub fn say_status<T, U>(&mut self, status: T, message: U, color: Color)
+ pub fn say_status<T, U>(&mut self,
+ status: T,
+ message: U,
+ color: Color,
+ justified: bool)
-> CargoResult<()>
where T: fmt::Display, U: fmt::Display
{
try!(self.reset());
if color != BLACK { try!(self.fg(color)); }
if self.supports_attr(Attr::Bold) { try!(self.attr(Attr::Bold)); }
- try!(write!(self, "{:>12}", status.to_string()));
+ if justified {
+ try!(write!(self, "{:>12}", status.to_string()));
+ } else {
+ try!(write!(self, "{}", status));
+ }
try!(self.reset());
try!(write!(self, " {}\n", message));
try!(self.flush());
// and for others, e.g. docopt version info, print to stdout.
fn output(err: String, shell: &mut MultiShell, fatal: bool) {
let (std_shell, color, message) = if fatal {
- (shell.err(), RED, Some("error"))
+ (shell.err(), RED, Some("error:"))
} else {
(shell.out(), BLACK, None)
};
let _ = match message{
- Some(text) => std_shell.say_status(text, err.to_string(), color),
+ Some(text) => std_shell.say_status(text, err.to_string(), color, false),
None => std_shell.say(err, color)
};
}
let hide = unknown && shell.get_verbose() != Verbose;
if hide {
- let _ = shell.err().say_status("error", "An unknown error occurred", RED);
+ let _ = shell.err().say_status("error:", "An unknown error occurred",
+ RED, false);
} else {
output(error.to_string(), shell, fatal);
}
things.push_str(&missing.last().unwrap());
try!(config.shell().warn(
- &format!("warning: manifest has no {things}. \
+ &format!("manifest has no {things}. \
See http://doc.crates.io/manifest.html#package-metadata for more info.",
things = things)))
}
}
}
let msg = format!("waiting for file lock on {}", msg);
- try!(config.shell().err().say_status("Blocking", &msg, CYAN));
+ try!(config.shell().err().say_status("Blocking", &msg, CYAN, true));
block().chain_error(|| {
human(format!("failed to lock file: {}", path.display()))
profiles,
publish);
if project.license_file.is_some() && project.license.is_some() {
- manifest.add_warning(format!("warning: only one of `license` or \
- `license-file` is necessary"));
+ manifest.add_warning(format!("only one of `license` or \
+ `license-file` is necessary"));
}
for warning in warnings {
manifest.add_warning(warning.clone());
if details.version.is_none() && details.path.is_none() &&
details.git.is_none() {
- cx.warnings.push(format!("warning: dependency ({}) specified \
+ cx.warnings.push(format!("dependency ({}) specified \
without providing a local path, Git \
repository, or version to use. This will \
be considered an error in future \
kinds.iter().filter_map(|s| {
let kind = LibKind::from_str(s);
if let Err(ref error) = kind {
- warnings.push(format!("warning: {}", error))
+ warnings.push(error.to_string());
}
kind.ok()
}).collect()
pub static RUNNING: &'static str = " Running";
pub static COMPILING: &'static str = " Compiling";
-pub static ERROR: &'static str = " error";
+pub static ERROR: &'static str = "error:";
pub static DOCUMENTING: &'static str = " Documenting";
pub static FRESH: &'static str = " Fresh";
pub static UPDATING: &'static str = " Updating";
assert_that(foo.cargo_process("build"),
execs().with_status(0).with_stderr("\
-unused manifest key: target.foo.bar
+warning: unused manifest key: target.foo.bar
"));
});
"#);
assert_that(p.cargo_process("build"),
execs().with_status(0)
- .with_stderr("unused manifest key: project.bulid\n"));
+ .with_stderr("\
+warning: unused manifest key: project.bulid
+"));
let mut p = project("bar");
p = p
"#);
assert_that(p.cargo_process("build"),
execs().with_status(0)
- .with_stderr("unused manifest key: lib.build\n"));
+ .with_stderr("\
+warning: unused manifest key: lib.build
+"));
});
test!(self_dependency {
{error} binary `foo[..]` already exists in destination as part of `[..]`
", error = ERROR)));
assert_that(good, execs().with_status(0).with_stderr("\
-be sure to add `[..]` to your PATH [..]
+warning: be sure to add `[..]` to your PATH [..]
"));
assert_that(cargo_home(), has_installed_exe("foo"));
execs().with_status(0).with_stdout(&format!("\
{installing} [..]
", installing = INSTALLING)).with_stderr("\
-be sure to add `[..]` to your PATH to be able to run the installed binaries
+warning: be sure to add `[..]` to your PATH to be able to run the installed binaries
"));
assert!(p.build_dir().c_exists());